<style>
  #mask_report{height: 100% !important;  background-color:#ccc;  opacity:0.5;  filter: alpha(opacity=50);  position:absolute;  left:0;  top:0;  z-index:1000;}
  #login_report{  position:fixed;  width: 750px;  height: 450px;  z-index:1001;  background: white;  border-radius: 15px;overflow-y: scroll;  }
  #login_report img{width:100%;}
  .fornum_report{
    margin:15px 15px 30px 15px;
  }
  .content_forum{
    background-color: mintcream;
    padding:30px 15px 30px 15px;
    border-radius: 15px;
    border: 2px solid cornflowerblue;
    margin-bottom: 10px;
    margin-top: 5px;
  }
  .content_reason{
    background-color: mintcream;
    padding:5px 5px 30px 15px;
    border-radius: 15px;
    border: 2px solid firebrick;
    margin-bottom: 10px;
    margin-top: 5px;
    min-height:50px;
  }
</style>
<div style="min-height:400px;">
    <div class="weui-cells__title">
        论坛举报列表
    </div>
  <div class="weui-cell weui-cell_access">
    <div class="weui-cell__bd"><small>编号</small></div>
    <div class="weui-cell__bd"><small>举报内容</small></div>
    <div class="weui-cell__bd"><small>举报原因</small></div>
    <div class="weui-cell__bd"><small>举报时间</small></div>
    <div class="weui-cell__bd"><small>处理时间</small></div>
    <div class="weui-cell__bd"><small>举报人</small></div>
    <div class="weui-cell__bd"><small>状态</small></div>
    <div class="weui-cell__bd"><small>处理人员</small></div>
    <div class="weui-cell__bd"><small>操作</small></div>
  </div>
  <div class="weui-cells" id="report">

  </div>
  <div id="page-report" style="text-align: center"></div>
</div>

<sss>
initPageData()
function openNew2() {
    //获取页面的高度和宽度
    var sWidth=document.body.scrollWidth;
    var sHeight=document.body.scrollHeight;
    //获取页面的可视区域高度和宽度
    var wHeight=document.documentElement.clientHeight;
    var oMask=document.createElement("div");
    oMask.id="mask_report";
    oMask.style.height=sHeight+"px";
    oMask.style.width=sWidth+"px";
    document.body.appendChild(oMask);
    var oLogin=document.createElement("div");
    oLogin.id="login_report";
    oLogin.innerHTML="<div class='loginCon'><div id='close' style='position: absolute; right: 0; top: 0;'><i class='weui-icon weui-icon-cancel weui-icon-original' style='font-size: 25px;'></i></div></div>";
    document.body.appendChild(oLogin);
    //获取登陆框的宽和高
    var dHeight=oLogin.offsetHeight;
    var dWidth=oLogin.offsetWidth;
    //设置登陆框的left和top
    oLogin.style.left=sWidth/2-dWidth/2+"px";
    oLogin.style.top=wHeight/2-dHeight/2+"px";
    //点击关闭按钮
    var oClose=document.getElementById("close");
    //点击登陆框以外的区域也可以关闭登陆框
    oClose.onclick=oMask.onclick=function(){
      document.body.removeChild(oLogin);
      document.body.removeChild(oMask);
    };
  }
function initPageData (pages) {
  $.ajax({
    url: 'http://api.hongyanche.com/forum_admin/accusation_list',
    type: 'GET',
    data: {
      page: pages
    },
    xhrFields:{
                  withCredentials:true
    },
    success: function (data) {
      if (data.state) {
        var datas = data.data.list;
        $('#report').html(' ');
        $('#page-report').html(data.page)
        datas.forEach(function (item, index) {
          let handle= "";
          if(item.state == 1){
            handle = "未处理";
          }else if(item.state == 2){
            handle ="已处理";
          }else{
            handle = "暂不处理";
          }
          $('#report').append(`
              <div class="weui-cell weui-cell_access">
                <div class="weui-cell__bd"><small>${item.accusation_id}</small></div>
                <div class="weui-cell__bd"><small>${item.title}</small></div>
                <div class="weui-cell__bd"><small >${item.reason}</small></div>
                <div class="weui-cell__bd"><small>${item.create_time}</small></div>
                <div class="weui-cell__bd"><small>${item.processing_time}</small></div>
                <div class="weui-cell__bd"><small>${item.user_name}</small></div>
                <div class="weui-cell__bd"><small>${handle}</small></div>
                <div class="weui-cell__bd"><small>${item.admin_user_name}</small></div>
                <div class="weui-cell__bd">
                  <a href="javascript:void(0)" data-id="${item.accusation_id}" class="look_report weui-btn weui-btn_mini weui-btn_primary">查看</a>
                  <a href="javascript:void(0)" data-id="${item.accusation_id}" class="remove_report weui-btn weui-btn_mini weui-btn_warn">删除</a>
                </div>
              </div>
          `)
        })
      }
    }
  })
}
$('body').on('click', '.look_report', function () {
    let ID = $(this).attr('data-id');
    $.ajax({
       url: 'http://api.hongyanche.com/forum_admin/get_accusation_info',
       type: 'POST',
       xhrFields:{
       withCredentials:true
       },
       data: {
         accusation_id: ID
       },
       success: function (data) {
         if(data.state == 1){
            openNew2();
            $("#login_report").append(`
            <div class="fornum_report">
              <div class="fornum_report_title">
                <div class="title" style="background-color:cornflowerblue;border-radius: 15px;"><h2>举报内容</h2></div>
                <div class="content_forum">${data.data.info.content}</div>
              </div>
              <div class="fornum_report_reason">
                <div class="title" style="background-color:firebrick;border-radius: 15px;"><h2>举报原因</h2></div>
                <div class="content_reason">${data.data.info.reason}</div>
              </div>
              <div class="fornum_report_button">
                <a href="javascript:void(0)" data-id="${ID}" class="fornum_report_button_remove weui-btn weui-btn_mini weui-btn_warn">删除当前内容</a>
                <a href="javascript:void(0)" data-id="${ID}" class="fornum_report_button_not_work weui-btn weui-btn_mini weui-btn_primary">不做处理</a>
                <a href="http://www.hongyanche.com/forum/posts/${data.data.info.forum_id}"  class="weui-btn weui-btn_mini weui-btn_warn">查看当前举报内容</a>
              </div>
            </div>
            `);
         }
       }
     })
   });
$('body').on('click', '.fornum_report_button_remove', function () {
    let ID = $(this).attr('data-id')
    $.ajax({
      url: 'http://api.hongyanche.com/forum_admin/accusation_handle',
      type: 'POST',
      xhrFields:{
      withCredentials:true
    },
      data: {
        accusation_id: ID,
        release:1
      },
      success: function (data) {
        if(data.state == 1){
          alert("处理成功");
          $('#report').html(' ');
          $('#login_report').remove();
          $('#mask_report').remove()
          initPageData()
        }else{
          alert("处理失败");
        }
      }
    })
  })
$('body').on('click', '.fornum_report_button_not_work', function () {
      let ID = $(this).attr('data-id')
      $.ajax({
        url: 'http://api.hongyanche.com/forum_admin/accusation_handle',
        type: 'POST',
        xhrFields:{
        withCredentials:true
      },
        data: {
          accusation_id: ID,
          release:0
        },
        success: function (data) {
          if(data.state == 1){
            alert("处理成功");
            $('#report').html(' ');
            $('#login_report').remove();
            $('#mask_report').remove()
            initPageData()
          }else{
            alert("处理失败");
          }
        }
      })
    })
$('body').on('click', '.remove_report', function () {
        let ID = $(this).attr('data-id')
        $.ajax({
          url: 'http://api.hongyanche.com/forum_admin/accusation_rmove',
          type: 'POST',
          xhrFields:{
          withCredentials:true
        },
          data: {
            accusation_id: ID
          },
          success: function (data) {
            if(data.state == 1){
              alert("删除成功");
              $('#report').html(' ');
              initPageData()
            }else{
              alert("删除失败");
            }
          }
        })
      })
  function ajax_page_report(num, e) {
    initPageData(num)
  }
</sss>
